package com.baicaoyuan.web.repository;


import com.baicaoyuan.web.model.StockApplyDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 功能描述：需求发布
 *
 * @author 罗富祥
 * 创建时间： 2018/1/4
 * 版权：
 */
@Repository
public interface StockApplyRepository extends JpaRepository<StockApplyDO, Long> {

    /**
     * 获取申请列表
     *
     * @param page
     * @param size
     * @return
     */
    @Query(value = "select * from t_stock_apply where status = ?3  order by create_time desc Limit ?1,?2", nativeQuery = true)
    List<StockApplyDO> getStockApply(Integer page, Integer size, String status);


    @Transactional
    @Modifying
    @Query(value = "update t_stock_apply set status = ?2 where id = ?1", nativeQuery = true)
    Integer updateStatus(Long id, String status);

    Integer countAllByStatusIs(String status);
}
